From 0d75438a329eeee631c4044c2e86f02e2bb46971 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 30 Jan 2009 11:04:24 +0000 Subject: [PATCH] x86: Better bzimage_headroom() crash fix. Signed-off-by: Joseph Cihula --- xen/arch/x86/setup.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 1955b65684..6fbe1e4e4a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -417,7 +417,7 @@ void __init __start_xen(unsigned long mbi_p) unsigned int initrdidx = 1; multiboot_info_t *mbi = __va(mbi_p); module_t *mod = (module_t *)__va(mbi->mods_addr); - unsigned long nr_pages, modules_length, modules_headroom = -1; + unsigned long nr_pages, modules_length, modules_headroom; unsigned long allocator_bitmap_end; int i, e820_warn = 0, bytes = 0; struct ns16550_defaults ns16550 = { @@ -618,6 +618,12 @@ void __init __start_xen(unsigned long mbi_p) */ modules_length = mod[mbi->mods_count-1].mod_end - mod[0].mod_start; + /* ensure mod[0] is mapped before parsing */ + bootstrap_map(mod[0].mod_start, mod[0].mod_end); + modules_headroom = bzimage_headroom( + (char *)(unsigned long)mod[0].mod_start, + (unsigned long)(mod[0].mod_end - mod[0].mod_start)); + for ( i = boot_e820.nr_map-1; i >= 0; i-- ) { uint64_t s, e, mask = (1UL << L2_PAGETABLE_SHIFT) - 1; @@ -721,11 +727,6 @@ void __init __start_xen(unsigned long mbi_p) } #endif - if ( modules_headroom == -1 ) - modules_headroom = bzimage_headroom( - (char *)(unsigned long)mod[0].mod_start, - (unsigned long)(mod[0].mod_end - mod[0].mod_start)); - /* Is the region suitable for relocating the multiboot modules? */ if ( !initial_images_start && (s < e) && ((e-s) >= (modules_length+modules_headroom)) ) -- 2.30.2